package com.jml.service;

import com.jml.feign.MemberServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
public class OrderServiceImpl {

    @Autowired
    private MemberServiceFeign memberServiceFeign;

    @RequestMapping("/order")
    public String getOrder(Integer userId){
        ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        log.info("TraceId:"+request.getHeader("X-B3-TraceId")+",spanId:"+request.getHeader("X-B3-SpanId"));
        String user = memberServiceFeign.getUser(userId);
        log.info("user:{}",user);
        return user;
    }


}
